package com.cn.longdistancebusstation.scenic.order;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.Html;
import android.webkit.WebView;
import android.widget.Toast;

import com.cn.longdistancebusstation.R;
import com.cn.longdistancebusstation.base.BaseActivity;
import com.cn.longdistancebusstation.httpHelper.HttpHelper;
import com.cn.longdistancebusstation.httpapi.HttpService;
import com.cn.longdistancebusstation.model.ListResultIII;
import com.cn.longdistancebusstation.model.ScenicDetails;
import com.cn.longdistancebusstation.scenic.ScenicDetailsActivity;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;

/**
 * Created by mucheng on 2018/4/13.
 */

public class ScheduleNoteActivity extends BaseActivity{
    private ScenicDetails mScenicDetail;
    private WebView mNoteWebView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_schedule_note);
        getTitleTextView().setText("预定须知");
        initView();


    }

    private void initView() {
        mNoteWebView=(WebView)findViewById(R.id.schedule_note);
        SharedPreferences sharedPreferences = getSharedPreferences("data", MODE_PRIVATE);
        String note = sharedPreferences.getString("note", "");
        StringBuilder sb = new StringBuilder();
        //拼接一段HTML代码
        sb.append("<html>");
        sb.append("<head>");
        sb.append("<title></title>");
        sb.append("</head>");
        sb.append("<body>");
        sb.append("<h2>"+note+"</h2>");
        sb.append("</body>");
        sb.append("</html>");
        //使用简单的loadData方法会导致乱码，可能是Android API的Bug
        //show.loadData(sb.toString(), "text/html", "utf-8");
        //加载、并显示HTML代码
        String content = Html.fromHtml(note).toString();
        mNoteWebView.loadDataWithBaseURL(null,content, "text/html", "utf-8", null);
        mNoteWebView.getSettings().setJavaScriptEnabled(true);
        mNoteWebView.getSettings().setDefaultTextEncodingName("UTF_8");
        mNoteWebView.setBackgroundColor(0);
    }

}
